<?php

namespace app\api\validate;

use think\Validate;

class Address extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'name' => 'require',
        'phone' => 'require|max:11|/^1[3-8]{1}[0-9]{9}$/',
        'city' => 'require',
        'address' => 'require',


    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'name.require' => '请填写收货人姓名',
        'phone.require' => '请填写手机号',
        'phone.max' => '手机号码不能超过11位',
        'phone./^1[3-8]{1}[0-9]{9}$/' => '手机号码格式不正确',
        'city.require' => '请选择地区',
        'address.require' => '请输入详细地址',
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add' => ['name','phone','city','address'],
        'edit' => ['name','phone','city','address'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'username' => __('Username'),
            'nickname' => __('Nickname'),
            'password' => __('Password'),
            'email' => __('Email'),
            'mobile' => __('Mobile')
        ];
        parent::__construct($rules, $message, $field);
    }

}
